package com.hotchpotch.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;

import com.hotchpotch.R;
import com.hotchpotch.base.BaseActivity;
import com.hotchpotch.inter.OnDeletePopClickListener;
import com.hotchpotch.tool.UpdateApk.UpdateService;
import com.hotchpotch.tool.popwindow.DeletePopwindow;
import com.hotchpotch.util.Logg;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/10/26 0026.
 */

public class UpdateApkActivity extends BaseActivity {
    private static final String TAG = "更新APK";
    private DeletePopwindow popwindow;
    @BindView(R.id.update_apk_btn)
    Button button;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_update_apk;
    }

    @Override
    protected void initView() {
        popwindow = new DeletePopwindow(UpdateApkActivity.this, "是否继续检测更新？");
    }

    @Override
    protected void initEvents() {
        popwindow.setPopDeleteOnClickListener(new OnDeletePopClickListener() {
            @Override
            public void leftClick() {

            }

            @Override
            public void rightClick() {
                //启动服务
                Intent service = new Intent(UpdateApkActivity.this, UpdateService.class);
                startService(service);
            }
        });
        button.setOnClickListener(onClickListener);
    }

    @Override
    protected void initData() {
        Logg.e(TAG, "启动运行服务");
    }

    private View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.update_apk_btn:
                    popwindow.showView(view);
                    break;
            }
        }
    };

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
